using System;
using System.Collections.Generic;
using System.Text;

namespace KNCApp.Util
{
    class CmnTools
    {
        public CmnTools()
        {
        }

        public static decimal ConvertToDecimal(string str)
        {
            decimal res = 0;
            string nStr = str;

            string sep = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
            try
            {
                if (nStr != null && nStr.Length > 0)
                {
                    if (nStr.IndexOf(sep) == -1)
                    {
                        nStr = nStr.Replace(".", sep);
                        nStr = nStr.Replace(",", sep);
                    }
                    res = Decimal.Parse(nStr, System.Globalization.NumberStyles.Float);
                }
            }
            catch
            {
                res = 0;
            }
            return res;
        }
    }
}
